package cn.lcsjsxy.yxz.areviewofoperators;

import java.util.Objects;

public class Customer {

    private  String name;
    private int age;

    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public Customer(int age, String name) {
        this.age = age;
        this.name = name;
    }
    public Customer(){

    }

    //重写的原则:
    //比较两个对象的实体内容是否相同(name,age)

    //手搓equals重写!
//    @Override
//    public boolean equals(Object obj) {
//
//        System.out.println("Customer equals()......");
//        if (this == obj){
//            return true;
//        }
//
//        if (obj instanceof Customer){
//            Customer cust = (Customer) obj;
//            //比较
//            /*if (this.age == cust.age && this.name.equals(cust.name)){
//                return true;
//            }else {
//                return false;
//            }*/
//            //或
//            return this.age == cust.age && this.name.equals(cust.name);
//        }else {
//            return false;
//        }
//
//    }

    //生成
    @Override
    public String toString(){
        return "Customer[name = " + name + ",age = " + age + "]";
    }

//    @Override
//    public String toString(){
//        return "Customer [name = " + name + ", age = " + age + "]";
//    }

}

